package com.qfedu.luck.controller;

import com.alibaba.fastjson.JSON;
import com.qfedu.luck.entity.User;
import com.qfedu.luck.service.UserService;
import com.qfedu.luck.service.impl.UserServiceImpl;
import com.qfedu.luck.vo.R;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: LuckStudy
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-02-24 15:00
 */
@WebServlet("/api/user/save.do")
public class UserAddServlet extends HttpServlet {

    private UserService service=new UserServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        User user=new User();
        user.setPhone(req.getParameter("phone"));
        user.setPwd(req.getParameter("pwd"));
        R r=service.add(user);
        resp.setContentType("application/json;charset=UTF-8");
        resp.getWriter().print(JSON.toJSONString(r));
    }
}
